package com.example.gustavo.hello.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyPattern {
	/**
     * 判断是否包含中文   中文的编码范围
     * @param str
     * @return
     */
    public static boolean isChinese(String str){
        Pattern pattern = Pattern.compile("^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$");
        Matcher matcher = pattern.matcher(str);
        return matcher.find();
    }
	/**
     *
     * @param phone
     * @return
     *
     * 170虚拟运营商专属号段，电信是1700；联通是1709；移动是1705
     */
	public static boolean isPhoneNumber(String phone) {
    	String regex = "^1[3578]\\d{9}$|^147\\d{8}$";   
        Pattern p = Pattern.compile(regex);   
        Matcher matcher = p.matcher(phone);   
       
        return matcher.find();
    }
	
	public boolean isEmail(String email){
        String regularExpression = "^\\w++@\\w++(.\\w++)++$";
        Pattern pattern = Pattern.compile(regularExpression);
        Matcher matcher = pattern.matcher(email);

        return matcher.find();
    }
}